package com.atguigu.gmall.item.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.locks.ReentrantLock;

@RestController
@RequestMapping("api/item")
public class ItemController {
    @Autowired
    private ItemService itemService;

    @GetMapping("{skuId}")
    public Result getItemById(@PathVariable Long skuId) {
        Map<String, Object> map = itemService.getItemBySkuId(skuId);
        return Result.ok(map);
    }

        public Result Login(@PathVariable Long id, HttpServletRequest request) {
            //1.前端直接给你id
            //2.拿http请求解析
            HttpSession session = request.getSession();
            String id2 = session.getId();
            return Result.ok();



        }

    public static void main(String[] args) throws InterruptedException {
        ReentrantLock reentrantLock = new ReentrantLock();
        reentrantLock.lock();


        Thread.sleep(5000L);
        reentrantLock.unlock();
    }
}
